<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<div id="app">
			
			<h2>{{getFullName()}}</h2>
			<h2>{{fullName}}</h2>
			<ul>
				<li v-for="item in books">书名：{{item.name}}  ¥ {{item.price}}</li>
			</ul>
			<h2>总价格{{totalPrice}}</h2>
		</div>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			const app = new Vue({
				el: '#app',
				data: {
					//简单操作
					firstName: 'Landeng',
					lastName: 'James',
					//复杂操作
					books: [
						{id:110, name: 'Unix编程艺术', price: 89},
						{id:111, name: 'JavaScript从入门到精通', price: 99},
						{id:112, name: '代码大全', price: 180},
						{id:113, name: '深入理解计算机原理', price: 149},
						{id:114, name: '现代操作系统', price: 109},
						
					]
				},
				computed: {
					//计算属性
					fullName: function () {
						return this.firstName + ' ' + this.lastName
					},
					//
					totalPrice: function () {
						return this.books.reduce((accumulator, currentValue) => accumulator + currentValue.price,0)
					}
				},
				methods: {
					getFullName: function () {
						return this.firstName+ ' ' +this.lastName
					}
				}
			
			})
		</script>
	</body>
</html>
